C----------------------------------------------------------------------------

C  Module name: PHIGS windows.

C  Author: Gareth Williams.

C  Function: This module contains functions for displaying PHIGS structures
C            in windows.

C  Dependencies:

C  Internal function list: 

C  External function list: 

C  Hashtables used: "structureid", "name", "label", "viewindex".

C  Modification history: (Version), (Date), (name), (Description).

C  1.0, 5th September 1991, G. Williams, First version.

C----------------------------------------------------------------------------

       SUBROUTINE ptkf_createwindow(wsid, windid, size, position,
& titlestr)
C /* 
C ** \parambegin
C ** \param{INTEGER}{wsid}{workstation identifier}{IN}
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{size(2)}{window size}{IN}
C ** \param{REAL}{position(2)}{window position}{IN}
C ** \param{CHARACTER*(*)}{titlestring}{title string}{IN}
C ** \paramend
C ** \blurb{This function creates a window structure which may be used
C ** for viewing PHIGS structures, PHIGS Toolkit topology diagrams and
C ** PHIGS Toolkit structure content diagrams. A terminal window
C ** type which contains only text. The window size and position are
C ** given in the range [0, 1]. Each window has a virtual camera
C ** which is useful for moving around a scene.}
C */
       INTEGER wsid, windid
       REAL size(2), position(2)
       CHARACTER*(*) titlestr
       CHARACTER*255 inbuf
       external ptk_createwindow !$PRAGMA C(ptk_createwindow)

       inbuf = titlestr//'\0'
       call ptk_createwindow(%val(wsid), %val(windid), size, position, 
& inbuf)

       RETURN
       END

       SUBROUTINE ptkf_setwindowattrs(windid, titlefont, titlecol,
& bannercol, backgdcol, edgecol, frametlcol, framebrcol)
C /* 
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{INTEGER}{titlefont}{title string font}{IN}
C ** \param{INTEGER}{titlecol}{title string colour index}{IN}
C ** \param{INTEGER}{bannercol}{banner colour index}{IN}
C ** \param{INTEGER}{backgdcol}{background colour index of window}{IN}
C ** \param{INTEGER}{edgecol}{edge colour index of window}{IN}
C ** \param{INTEGER}{frametlcol}{top-left frame colour index}{IN}
C ** \param{INTEGER}{framebrcol}{bottom-right frame colour index}{IN}
C ** \paramend
C ** \blurb{This function sets the window text font and colour attribute
C ** values. Each window has a banner region which contains the title
C ** string of the window. The text font value applies to this string.} 
C */
       INTEGER windid, titlefont, titlecol, bannercol
       INTEGER backgdcol, edgecol, frametlcol, framebrcol
       external ptk_setwindowattrs !$PRAGMA C(ptk_setwindowattrs)

       call ptk_setwindowattrs(%val(windid), %val(titlefont),
& %val(titlecol), %val(bannercol), %val(backgdcol), 
& %val(edgecol), %val(frametlcol), %val(framebrcol))

       RETURN
       END

       SUBROUTINE ptkf_inqwindowattrs(windid, titlefont, titlecol,
& bannercol, backgdcol, edgecol, frametlcol, framebrcol, err)
C /* 
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{INTEGER}{titlefont}{title string font}{OUT}
C ** \param{INTEGER}{titlecol}{title string colour index}{OUT}
C ** \param{INTEGER}{bannercol}{banner colour index}{OUT}
C ** \param{INTEGER}{backgdcol}{background colour index of window}{OUT}
C ** \param{INTEGER}{edgecol}{edge colour index of window}{OUT}
C ** \param{INTEGER}{frametlcol}{top-left frame colour index}{OUT}
C ** \param{INTEGER}{framebrcol}{bottom-right frame colour index}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain the text font and
C ** colour attribute values of a window.}
C */
       INTEGER windid, titlefont, titlecol, bannercol
       INTEGER backgdcol, edgecol, frametlcol, framebrcol, err
       external ptk_inqwindowattrs !$PRAGMA C(ptk_inqwindowattrs)

       call ptk_inqwindowattrs(%val(windid), titlefont,
& titlecol, bannercol, backgdcol, 
& edgecol, frametlcol, framebrcol, err)

       RETURN
       END

       SUBROUTINE ptkf_posttowindow(windid, id)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{INTEGER}{id}{item identifier}{IN}
C ** \paramend
C ** \blurb{This function posts an item to a window depending on the 
C ** window type. In the case
C ** of STRUCT and CONTENT windows, {\tt id} is a structure identifier.
C ** For TOPOLOGY windows, {\tt id} is a topology identifier. If the window is
C ** a TERMINAL window this function is ignored.}
C */
       INTEGER windid, id
       external ptk_posttowindow !$PRAGMA C(ptk_posttowindow)

       call ptk_posttowindow(%val(windid), %val(id))

       RETURN
       END

       SUBROUTINE ptkf_unpostfromwindow(windid, id)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{INTEGER}{id}{item identifier}{IN}
C ** \paramend
C ** \blurb{This function unposts an item from a window depending on the
C ** window type. In the case
C ** of STRUCT and CONTENT windows, id is a structure identifier.
C ** For TOPOLOGY windows, id is a topology identifier. If the window is
C ** a TERMINAL window this function is ignored.}
C */
       INTEGER windid, id
       external ptk_unpostfromwindow !$PRAGMA C(ptk_unpostfromwindow)

       call ptk_unpostfromwindow(%val(windid), %val(id))

       RETURN
       END

       SUBROUTINE ptkf_unpostallfromwindow(windid)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \paramend 
C ** \blurb{This function unposts all items posted to window {\tt windid}.}
C */
       INTEGER windid
       external ptk_unpostallfromwindow 
& !$PRAGMA C(ptk_unpostallfromwindow)

       call ptk_unpostallfromwindow(%val(windid))

       RETURN
       END

       SUBROUTINE ptkf_postwindow(windid)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \paramend
C ** \blurb{This function posts a window structure to the workstation
C ** specified when the window was initially created. Windows are bound
C ** to workstation because they each use one view table entry to
C ** define the window view. The priority of the window structure is
C ** controlled by the PHIGS Toolkit window system to provide an ordered
C ** stacking mechanism for windows.}
C */
       INTEGER windid
       external ptk_postwindow !$PRAGMA C(ptk_postwindow)

       call ptk_postwindow(%val(windid))

       RETURN
       END

       SUBROUTINE ptkf_unpostwindow(windid)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \paramend
C ** \blurb{This function unposts a window from the workstation it is
C ** bound to.}
C */
       INTEGER windid
       external ptk_unpostwindow !$PRAGMA C(ptk_unpostwindow)

       call ptk_unpostwindow(%val(windid))

       RETURN
       END

       LOGICAL FUNCTION ptkf_delwindow(windid)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \paramend
C ** \blurb{This function deletes a window from the PHIGS Toolkit window
C ** store.}
C */
       INTEGER windid
       external ptk_delwindow !$PRAGMA C(ptk_delwindow)

       ans = ptk_delwindow(%val(windid))
       if (ans .eq. 1) then
          ptkf_delwindow = .TRUE.
       else
          ptkf_delwindow = .FALSE.
       endif

       RETURN
       END

       SUBROUTINE ptkf_closewindow(windid)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \paramend 
C ** \blurb{This function posts the icon structure and unposts the window
C ** structure from the window's workstation.}
C */
       INTEGER windid
       external ptk_closewindow !$PRAGMA C(ptk_closewindow)

       call ptk_closewindow(%val(windid))

       RETURN
       END

       SUBROUTINE ptkf_openwindow(windid)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \paramend 
C ** \blurb{This function posts the window structure and unposts the icon
C ** structure from the window's workstation.}
C */
       INTEGER windid
       external ptk_openwindow !$PRAGMA C(ptk_openwindow)

       call ptk_openwindow(%val(windid))

       RETURN
       END

       SUBROUTINE ptkf_setwindowposition(windid, position)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{position(2)}{window position}{IN}
C ** \paramend 
C ** \blurb{This function sets the position of the centre of the window.
C ** The position is given in the range [0, 1]. If the position results
C ** in part of the window being clipped then the position is adjusted
C ** so that the whole window is visible.}
C */
       INTEGER windid
       REAL position(2)
       external ptk_setwindowposition !$PRAGMA C(ptk_setwindowposition)

       call ptk_setwindowposition(%val(windid), position)

       RETURN
       END

       SUBROUTINE ptkf_setwindowsize(windid, size)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{size(2)}{window size}{IN}
C ** \paramend 
C ** \blurb{This function sets the size of the window using the x value
C ** as the width and the y value as the height. The values are given
C ** in the range [0, 1]. If the size results in part of the window
C ** being clipped then the window size is adjusted to give as large a
C ** window as possible.}
C */
       INTEGER windid
       REAL size(2)
       external ptk_setwindowsize !$PRAGMA C(ptk_setwindowsize)

       call ptk_setwindowsize(%val(windid), size)

       RETURN
       END

       SUBROUTINE ptkf_setwindowtraninputpri(windid, refwindid, 
& priority)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{INTEGER}{refwindid}{reference window identifier}{IN}
C ** \param{INTEGER}{priority}{relative priority}{IN}
C ** \paramend 
C ** \blurb{This function sets the transformation input priority of the 
C ** window's view representation relative to another window.
C ** The relative priority is also set relative to view index 0.}
C */
       INTEGER windid, refwindid, priority
       external ptk_setwindowtraninputpri 
& !$PRAGMA C(ptk_setwindowtraninputpri)

       call ptk_setwindowtraninputpri(%val(windid), %val(refwindid), 
& %val(priority))

       RETURN
       END

       SUBROUTINE ptkf_setframesize(windid, size)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{size(2)}{frame size}{IN}
C ** \paramend 
C ** \blurb{This function sets the thickness of the window frame. The
C ** x and y dimensions are given in the range [0, 1].}
C */
       INTEGER windid
       REAL size(2)
       external ptk_setframesize !$PRAGMA C(ptk_setframesize)

       call ptk_setframesize(%val(windid), size)

       RETURN
       END
       
       LOGICAL FUNCTION ptkf_stringscanwindows(wsid, str, windowid)
C /*
C ** \parambegin
C ** \param{INTEGER}{wsid}{workstation identifier}{IN}
C ** \param{CHARACTER*(*)}{str}{string}{IN}
C ** \param{INTEGER}{windowid}{window identifier}{OUT}
C ** \paramend
C ** \blurb{This function compares the character string {\tt str} with
C ** title string of all the windows posted to workstation {\tt wsid}.
C ** The string comparison is case sensitive and begins with the
C ** front window and works back to the lowest priority window.
C ** The function returns TRUE if a match is found, otherwise FALSE.}
C */
       INTEGER wsid
       CHARACTER*(*) str
       INTEGER windowid
       LOGICAL*1 ptk_stringscanwindows, ans
       external ptk_stringscanwindows !$PRAGMA C(ptk_stringscanwindows)

       ans = ptk_stringscanwindows(%val(wsid), str, windowid)
       if (ans .eq. 1) then
          ptkf_stringscanwindows = .TRUE.
       else
          ptkf_stringscanwindows = .FALSE.
       endif

       RETURN
       END

       LOGICAL FUNCTION ptkf_pickscanwindows(ippd, pp, ppordr, windowid)
C /*
C ** \parambegin
C ** \param{INTEGER}{ippd}{depth of pick path}{IN}
C ** \param{INTEGER}{pp(3, ippd)}{pick path through structure network.}{IN}
C ** \param{INTEGER}{ppordr}{order of data in pickpath}{IN}
C ** \param{INTEGER}{windowid}{window identifier}{OUT}
C ** \paramend
C ** \blurb{This function tests the pick path to inquire if a window 
C ** structure was picked. The window area picked may be one of
C ** BANNER, VIEW, FRAME or ICON. The function
C ** returns TRUE if a window was picked, otherwise FALSE.}
C */
       INTEGER ippd
       INTEGER pp(3, ippd)
       INTEGER ppordr
       INTEGER windowid
       LOGICAL*1 ptk_pickscanwindows, ans
       external ptk_pickscanwindows !$PRAGMA C(ptk_pickscanwindows)
       structure /Ppickpath/
         INTEGER depth
         INTEGER pick_path(3, 100)
       end structure
       record /Ppickpath/ ppath

       ppath.depth = ippd
       do 10, i=1,ippd
          ppath.pick_path(1, i) = pp(1, i)
          ppath.pick_path(2, i) = pp(2, i)
 10       ppath.pick_path(3, i) = pp(3, i)
       ans = ptk_pickscanwindows(ppath, %val(ppordr), windowid)
       if (ans .eq. 1) then
          ptkf_pickscanwindows = .TRUE.
       else
          ptkf_pickscanwindows = .FALSE.
       endif

       RETURN
       END

       LOGICAL FUNCTION ptkf_locscanwindows(wsid, point, windowid, 
& windarea, value)
C /*
C ** \parambegin
C ** \param{INTEGER}{wsid}{workstation identifier}{IN}
C ** \param{REAL}{point(2)}{input point}{IN}
C ** \param{INTEGER}{windowid}{window identifier}{OUT}
C ** \param{INTEGER}{windowarea}{window area}{OUT}
C ** \param{REAL}{value(2)}{position of point within window area}{OUT}
C ** \paramend
C ** \blurb{This function uses the INCREMENTAL SPATIAL SEARCH function 
C ** of PHIGS to test if {\tt point} lies within a window
C ** posted to workstation {\tt wsid}. The window area (one of
C ** BANNER, VIEW, FRAME or ICON) and the position of {\tt point} relative
C ** to the bottom-left corner of the bounding box of the window area are
C ** returned in {\tt windowarea} and {\tt value}.
C ** The function returns TRUE if {\tt point} lies within a window,
C ** otherwise FALSE.}
C */
       INTEGER wsid
       REAL point(2)
       INTEGER windowid, windarea
       REAL value(2)
       LOGICAL*1 ptk_locscanwindows, ans
       external ptk_locscanwindows !$PRAGMA C(ptk_locscanwindows)

       ans = ptk_locscanwindows(%val(wsid), point, windowid, windarea, 
& value)
       if (ans .eq. 1) then
          ptkf_locscanwindows = .TRUE.
       else
          ptkf_locscanwindows = .FALSE.
       endif

       RETURN
       END

       SUBROUTINE ptkf_frontwindow(windid)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \paramend 
C ** \blurb{This function sets the post priority of the window structure
C ** so that it is displayed on top of all other posted windows but
C ** has a lower prioity than the current back menu.}
C */
       INTEGER windid
       external ptk_frontwindow !$PRAGMA C(ptk_frontwindow)

       call ptk_frontwindow(%val(windid))

       RETURN
       END

       SUBROUTINE ptkf_backwindow(windid)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \paramend 
C ** \blurb{This function sets the post priority of a window structure
C ** so that it is displayed behind all the other posted windows and menus.}
C */
       INTEGER windid
       external ptk_backwindow !$PRAGMA C(ptk_backwindow)

       call ptk_backwindow(%val(windid))
 
       RETURN
       END

       SUBROUTINE ptkf_inqpostedwindows(wsid, num, windowids, totalnum,
& err)
C /*
C ** \parambegin
C ** \param{INTEGER}{wsid}{workstation identifier}{IN}
C ** \param{INTEGER}{num}{size of array}{IN}
C ** \param{INTEGER}{windowids(*)}{list of posted windows}{OUT}
C ** \param{INTEGER}{totalnum}{length of posted windows list}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain a list of all windows
C ** posted to the workstation {\tt wsid}.}
C */
       INTEGER wsid, num, windowids(num), totalnum, err
       external ptkc_inqpostedwindows !$PRAGMA C(ptkc_inqpostedwindows)

       call ptkc_inqpostedwindows(%val(wsid), %val(num), windowids, 
& totalnum, err)

       RETURN
       END

       SUBROUTINE ptkf_inqwindowids(num, windowids, totalnum, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{num}{size of array}{IN}
C ** \param{INTEGER}{windowids(*)}{list of windows}{OUT}
C ** \param{INTEGER}{totalnum}{length of windows list}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain a list of all
C ** windows in the PHIGS Toolkit window store.}
C */
       INTEGER num, windowids(num), totalnum, err
       external ptkc_inqwindowids !$PRAGMA C(ptkc_inqwindowids)

       call ptkc_inqwindowids(%val(num), windowids, totalnum, err)

       RETURN
       END

       SUBROUTINE ptkf_inqwindowstructid(windid, windowstid, iconstid,
& err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{INTEGER}{windowstid}{window structure identifier}{OUT}
C ** \param{INTEGER}{iconstid}{window structure identifier}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain the identifier of
C ** a window structure and its corresponding icon structure.
C ** The window structure is a network with references to all the items
C ** posted to the window. The default icon is a single structure
C ** containing the window identifier.}
C */
       INTEGER windid, windowstid, iconstid, err
       external ptk_inqwindowstructid !$PRAGMA C(ptk_inqwindowstructid)

       call ptk_inqwindowstructid(%val(windid), windowstid, iconstid,
& err)

       RETURN
       END

       SUBROUTINE ptkf_inqwindowname(windid, name, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{INTEGER}{name}{window name}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain the window name 
C ** to be used in namesets for the pick, invisibility and 
C ** highlighting filters.}
C */
       INTEGER windid, name, err
       external ptk_inqwindowname !$PRAGMA C(ptk_inqwindowname)

       call ptk_inqwindowname(%val(windid), name, err)

       RETURN
       END

       SUBROUTINE ptkf_inqwindowstate(windid, state, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{INTEGER}{state}{window state}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain the window state,
C ** open or closed.
C ** The error code = 1 if {\tt windid} doesn't exist.}
C */
       INTEGER windid, state, err
       external ptk_inqwindowstate !$PRAGMA C(ptk_inqwindowstate)

       call ptk_inqwindowstate(%val(windid), state, err)

       RETURN
       END

       LOGICAL FUNCTION ptkf_inqfrontbackwindowid(wsid, frontid, 
& frontstate, backid, backstate, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{wsid}{workstation identifier}{IN}
C ** \param{INTEGER}{frontstid}{front window identifier}{OUT}
C ** \param{INTEGER}{frontstate}{front window state}{OUT}
C ** \param{INTEGER}{backstid}{back window identifier}{OUT}
C ** \param{INTEGER}{backstate}{back window state}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain the identifiers
C ** of the front and back windows and there current state (OPEN or
C ** CLOSED).}
C */
       INTEGER wsid, frontid, frontstate, backid, backstate, err
       LOGICAL*1 ptk_inqfrontbackwindowid, ans
       external ptk_inqfrontbackwindowid 
& !$PRAGMA C(ptk_inqfrontbackwindowid)

       ans = ptk_inqfrontbackwindowid(%val(wsid), frontid, frontstate, 
& backid, backstate, err)
       if (ans .eq. 1) then
          ptkf_inqfrontbackwindowid = .TRUE.
       else
          ptkf_inqfrontbackwindowid = .FALSE.
       endif

       RETURN
       END

       SUBROUTINE ptkf_inqwindowposition(windid, position, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{position(2)}{window position}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain the position of the centre
C ** of a window. The position is returned in the range [0, 1].}
C */
       INTEGER windid
       REAL position(2)
       INTEGER err
       external ptk_inqwindowposition !$PRAGMA C(ptk_inqwindowposition)

       call ptk_inqwindowposition(%val(windid), position, err)

       RETURN
       END

       SUBROUTINE ptkf_inqwindowsize(windid, size, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{size(2)}{window size}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain the size of a window
C ** which is returned in the range [0, 1].}
C */
       INTEGER windid
       REAL size(2)
       INTEGER err
       external ptk_inqwindowsize !$PRAGMA C(ptk_inqwindowsize)

       call ptk_inqwindowsize(%val(windid), size, err)

       RETURN
       END

       SUBROUTINE ptkf_inqiconposition(windid, position, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{position(2)}{icon position}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain the position of the centre of 
C ** a window icon which is returned in the range [0, 1].}
C */
       INTEGER windid
       REAL position(2)
       INTEGER err
       external ptk_inqiconposition !$PRAGMA C(ptk_inqiconposition)

       call ptk_inqiconposition(%val(windid), position, err)

       RETURN
       END

       SUBROUTINE ptkf_inqiconsize(windid, size, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{size(2)}{icon size}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain the size of a window's icon
C ** structure and is returned in the range [0, 1].}
C */
       INTEGER windid
       REAL size(2)
       INTEGER err
       external ptk_inqiconsize !$PRAGMA C(ptk_inqiconsize)

       call ptk_inqiconsize(%val(windid), size, err)

       RETURN
       END

       SUBROUTINE ptkf_inqusericon(windid, iconstid, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{INTEGER}{iconstid}{user icon structure identifier}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain the identifier of a
C ** user created icon structure. The structure is referenced by the
C ** window's icon structure.}
C */
       INTEGER windid, iconstid, err
       external ptk_inqusericon !$PRAGMA C(ptk_inqusericon)

       call ptk_inqusericon(%val(windid), iconstid, err)

       RETURN
       END

       SUBROUTINE ptkf_inqframesize(windid, size, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{size(2)}{frame size}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain the dimensions of the
C ** window frame. They are returned in the range [0, 1] and the default
C ** dimensions are (0.01, 0.01).}
C */
       INTEGER windid
       REAL size(2)
       INTEGER err
       external ptk_inqframesize !$PRAGMA C(ptk_inqframesize)

       call ptk_inqframesize(%val(windid), size, err)

       RETURN
       END

       SUBROUTINE ptkf_inqwindowtype(windid, type, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{INTEGER}{type}{window type}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to inquire the type of a window.
C ** The available types are STRUCT, TOPOLOGY, CONTENT and TERMINAL.
C ** The default window type is STRUCT and may be used to view any PHIGS
C ** structures.}
C */
       INTEGER windid, type, err
       external ptk_inqwindowtype !$PRAGMA C(ptk_inqwindowtype)

       call ptk_inqwindowtype(%val(windid), type, err)

       RETURN
       END

       SUBROUTINE ptkf_inqbannerheight(windid, height, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{bannerheight}{height of banner}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend 
C ** \blurb{This function may be used to obtain the height of a window
C ** banner. It is returned in the range [0, 1].}
C */
       INTEGER windid
       REAL height
       INTEGER err
       external ptk_inqbannerheight !$PRAGMA C(ptk_inqbannerheight)

       call ptk_inqbannerheight(%val(windid), height, err)

       RETURN
       END

       SUBROUTINE ptkf_inqbannertitle(windid, len, titlestr, totlen,
& err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{INTEGER}{len}{length of string}{IN}
C ** \param{CHARACTER*(*)}{titlestr}{title string of banner}{IN}
C ** \param{INTEGER}{totlen}{actual length of string}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend 
C ** \blurb{This function may be used to obtain the title of a window.}
C */
       INTEGER windid, len
       CHARACTER*(*) titlestr
       INTEGER totlen, err
       CHARACTER*255 inbuf
       external ptk_inqbannertitle !$PRAGMA C(ptk_inqbannertitle)

       call ptk_inqbannertitle(windid, %val(len), titlestr, totlen,
& err) 
       totlen = totlen - 1
       if (len .le. 255) then
         titlestr = inbuf(1:totlen)
       endif

       RETURN
       END

C icon functions 

       SUBROUTINE ptkf_seticonposition(windid, position)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{position(2)}{icon position}{IN}
C ** \paramend 
C ** \blurb{This function sets the position of the centre
C ** of the window's icon structure.
C ** The position is given in the range [0, 1].}
C */
       INTEGER windid
       REAL position(2)
       external ptk_seticonposition !$PRAGMA C(ptk_seticonposition)

       call ptk_seticonposition(%val(windid), position)

       RETURN
       END

       SUBROUTINE ptkf_seticonsize(windid, size)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{size(2)}{icon size}{IN}
C ** \paramend 
C ** \blurb{This function sets the size of the window's icon structure.
C ** The size is given in the range [0, 1].}
C */
       INTEGER windid
       REAL size(2)
       external ptk_seticonsize !$PRAGMA C(ptk_seticonsize)

       call ptk_seticonsize(%val(windid), size)

       RETURN
       END

       SUBROUTINE ptkf_setusericon(windid, usericon)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{INTEGER}{user icon}{icon structure identifier}{IN}
C ** \paramend 
C ** \blurb{This function enables the application to specify a structure
C ** identifier to use as a window icon. The structure is executed from
C ** the window's default icon structure and the icon size and position
C ** functions still apply provided the user icon is defined within
C ** the World Coordinate range [0, 1].}
C */
       INTEGER windid, usericon
       external ptk_setusericon !$PRAGMA C(ptk_setusericon)

       call ptk_setusericon(%val(windid), %val(usericon))

       RETURN
       END

C banner functions 

       SUBROUTINE ptkf_setbannercolours(windid, bannercolour, 
& titlecolour)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{INTEGER}{bannercolour}{banner colour index}{IN}
C ** \param{INTEGER}{titlecolour}{title string colour index}{IN}
C ** \paramend 
C ** \blurb{This function sets the colour indicies of a window banner.
C ** It is useful for highlighting a current window, for example
C ** in a `point and click' window system.}
C */
       INTEGER windid, bannercolour, titlecolour
       external ptk_setbannercolours !$PRAGMA C(ptk_setbannercolours)

       call ptk_setbannercolours(%val(windid), %val(bannercolour), 
& %val(titlecolour))

       RETURN
       END

       SUBROUTINE ptkf_setbannerheight(windid, bannerheight)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{bannerheight}{height of banner}{IN}
C ** \paramend 
C ** \blurb{This function sets the height of the window banner to
C ** {\tt bannerheight} which is given in the range [0, 1]. The window
C ** title is re-scaled to fit the new height.}
C */
       INTEGER windid
       REAL bannerheight
       REAL*8 dpbannerheight
       external ptk_setbannerheight !$PRAGMA C(ptk_setbannerheight)

       dpbannerheight = bannerheight
       call ptk_setbannerheight(%val(windid), %val(dpbannerheight))

       RETURN
       END

       SUBROUTINE ptkf_setbannertitle(windid, titlestring)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{CHARACTER*(*)}{titlestring}{title string of window banner}{IN}
C ** \paramend 
C ** \blurb{This function sets the title string of a window. The title
C ** is displayed in the window banner and is automatically scaled to
C ** fit inside the banner area.}
C */
       INTEGER windid
       CHARACTER*(*) titlestring
       CHARACTER*255 inbuf
       external ptk_setbannertitle !$PRAGMA C(ptk_setbannertitle)

       inbuf = titlestring//'\0'
       call ptk_setbannertitle(%val(windid), inbuf)

       RETURN
       END

C terminal window functions

       SUBROUTINE ptkf_setterminaldata(windid, numlines, txfont, 
& txcolour)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{terminal window identifier}{IN}
C ** \param{INTEGER}{numlines}{number of lines in window}{IN}
C ** \param{INTEGER}{txfont}{text font}{IN}
C ** \param{INTEGER}{txcolour}{text colour}{IN}
C ** \paramend
C ** \blurb{This function sets the number of lines to be displayed in a 
C ** TERMINAL window and which text font and colour to use.}
C */
       INTEGER windid, numlines, txfont, txcolour
       external ptk_setterminaldata !$PRAGMA C(ptk_setterminaldata)

       call ptk_setterminaldata(%val(windid), %val(numlines), 
& %val(txfont), %val(txcolour))

       RETURN
       END

       SUBROUTINE ptkf_refreshterminal(windid)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{terminal window identifier}{IN}
C ** \paramend
C ** \blurb{This function refreshes the TERMINAL window so that the
C ** last text line is visible.}
C */
       INTEGER windid
       external ptk_refreshterminal !$PRAGMA C(ptk_refreshterminal)

       call ptk_refreshterminal(%val(windid))

       RETURN
       END

       SUBROUTINE ptkf_writeterminal(windid, str)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{terminal window identifier}{IN}
C ** \param{CHARACTER*(*)}{str}{string to write to window}{IN}
C ** \paramend
C ** \blurb{This function writes a character string to the current line
C ** of the TERMINAL window. A new line is started when the end of the
C ** current line is reached.}
C */
       INTEGER windid
       CHARACTER*(*) str
       CHARACTER*255 inbuf
       external ptk_writeterminal !$PRAGMA C(ptk_writeterminal)

       inbuf = str//'\0'
       call ptk_writeterminal(%val(windid), inbuf)

       RETURN
       END

       SUBROUTINE ptkf_writelnterminal(windid, str)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{terminal window identifier}{IN}
C ** \param{CHARACTER*(*)}{str}{string to write to window}{IN}
C ** \paramend
C ** \blurb{This function writes a character string to the current line
C ** of the TERMINAL window. A new line is started when the end of the current
C ** line is reached and at the next call to a TERMINAL write function.}
C */
       INTEGER windid
       CHARACTER*(*) str
       CHARACTER*255 inbuf
       external ptk_writelnterminal !$PRAGMA C(ptk_writelnterminal)

       inbuf = str//'\0'
       call ptk_writelnterminal(%val(windid), inbuf)

       RETURN
       END

       SUBROUTINE ptkf_clearterminal(windid)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{terminal window identifier}{IN}
C ** \paramend
C ** \blurb{This function empties the structure containing all the text
C ** written to the TERMINAL window.}
C */
       INTEGER windid
       external ptk_clearterminal !$PRAGMA C(ptk_clearterminal)

       call ptk_clearterminal(%val(windid))

       RETURN
       END

       SUBROUTINE ptkf_writeintterminal(windid, number)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{terminal window identifier}{IN}
C ** \param{INTEGER}{number}{integer to write to window}{IN}
C ** \paramend
C ** \blurb{This function writes an integer to a TERMINAL window.}
C */
       INTEGER windid, number
       external ptk_writeintterminal !$PRAGMA C(ptk_writeintterminal)

       call ptk_writeintterminal(%val(windid), %val(number))

       RETURN
       END

       SUBROUTINE ptkf_writefloatterminal(windid, number)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{terminal window identifier}{IN}
C ** \param{REAL}{number}{float number to write to window}{IN}
C ** \paramend
C ** \blurb{This function writes a floating point number to a TERMINAL window.}
C */
       INTEGER windid
       REAL number
       REAL*8 dpnumber
       external ptk_writefloatterminal 
& !$PRAGMA C(ptk_writefloatterminal)

       dpnumber = number
       call ptk_writefloatterminal(%val(windid), %val(dpnumber))

       RETURN
       END

       SUBROUTINE ptkf_setterminalfloatformat(windid, rformat)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{terminal window identifier}{IN}
C ** \param{CHARACTER*(*)}{rformat}{string giving C-type float number output style}{IN}
C ** \paramend
C ** \blurb{This function sets the format for writing floating-point numbers
C ** to a TERMINAL window. The format used is the same syntax as in the
C ** C language.}
C */
       INTEGER windid
       CHARACTER*(*) rformat
       CHARACTER*255 inbuf
       external ptk_setterminalfloatformat 
& !$PRAGMA C(ptk_setterminalfloatformat)

       inbuf = rformat//'\0'
       call ptk_setterminalfloatformat(%val(windid), inbuf)

       RETURN
       END

       SUBROUTINE ptkf_inqterminalfloatformat(windid, size, totalsize, 
& rformat, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{terminal window identifier}{IN}
C ** \param{INTEGER}{size}{size of buffer, in bytes, as allocated by application}{IN}
C ** \param{INTEGER}{totalsize}{actual size of buffer}{IN}
C ** \param{CHARACTER*(*)}{rformat}{string giving C-type float number output style}{IN}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain the floating-point used
C ** for writing floating-point numbers to a TERMINAL window.}
C */
       INTEGER windid, size, totalsize
       CHARACTER*(*) rformat
       INTEGER err
       external ptk_inqterminalfloatformat 
& !$PRAGMA C(ptk_inqterminalfloatformat)

       call ptk_inqterminalfloatformat(%val(windid), %val(size), 
& totalsize, rformat, err)

       RETURN
       END

       SUBROUTINE ptkf_inqterminalstructid(windid, termwinstid, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{terminal window identifier}{IN}
C ** \param{INTEGER}{termwinstid}{text structure identifier}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain the identifier of the
C ** structure used to display the text written to a TERMINAL window.}
C */
       INTEGER windid, termwinstid, err
       external ptk_inqterminalstructid 
& !$PRAGMA C(ptk_inqterminalstructid)

       call ptk_inqterminalstructid(%val(windid), termwinstid, err)

       RETURN
       END

       SUBROUTINE ptkf_inqterminaldata(windid, numlines, numcolumns,
& txfont, txcolour, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{terminal window identifier}{IN}
C ** \param{INTEGER}{numlines}{number of lines in window}{OUT}
C ** \param{INTEGER}{numcolmns}{number of columns in window}{OUT}
C ** \param{INTEGER}{txfont}{text font}{OUT}
C ** \param{INTEGER}{txcolour}{text colour}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain the number of lines
C ** displayed in a TERMINAL window and the number of characters in a line.
C ** Also the text font and colour used are returned in {\tt txfont} and
C ** {\tt txcolour}.}
C */
       INTEGER windid, numlines, numcolumns, txfont, txcolour, err
       external ptk_inqterminaldata !$PRAGMA C(ptk_inqterminaldata)

       call ptk_inqterminaldata(%val(windid), numlines, numcolumns,
& txfont, txcolour, err)

       RETURN
       END

       SUBROUTINE ptkf_scrollterminal(windid, scrolldir, numlines)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{terminal window identifier}{IN}
C ** \param{INTEGER}{scrolldir}{scroll direction (up or down)}{IN}
C ** \param{INTEGER}{numlines}{number of lines to scroll by}{IN}
C ** \paramend
C ** \blurb{This function scrolls the contents of the TERMINAL window
C ** either UP or DOWN by {\tt numlines}.}
C */
       INTEGER windid, scrolldir, numlines
       external ptk_scrollterminal !$PRAGMA C(ptk_scrollterminal)

       call ptk_scrollterminal(%val(windid), %val(scrolldir), 
& %val(numlines))

       RETURN
       END

C topology viewing functions 

       SUBROUTINE ptkf_settopologyviewarea(windid, viewarea)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{viewarea(4)}{area of topology to view}{IN}
C ** \paramend 
C ** \blurb{This function sets the viewing area of a topology diagram posted
C ** to a TOPOLOGY window. The area is defined in the range [0, 1].}
C */
       INTEGER windid
       REAL viewarea(4)
       external ptk_settopologyviewarea 
& !$PRAGMA C(ptk_settopologyviewarea)

       call ptk_settopologyviewarea(%val(windid), viewarea)

       RETURN
       END

       SUBROUTINE ptkf_inqtopologyviewarea(windid, viewarea, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{viewarea(4)}{area of topology to view}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend 
C ** \blurb{This function may be used to obtain the viewing area
C ** of a topology diagram posted to a TOPOLOGY window.}
C */
       INTEGER windid
       REAL viewarea(4)
       INTEGER err
       external ptk_inqtopologyviewarea 
& !$PRAGMA C(ptk_inqtopologyviewarea)

       call ptk_inqtopologyviewarea(%val(windid), viewarea, err)

       RETURN
       END

C structure content viewing functions 

       SUBROUTINE ptkf_setcontentviewrange(windid, range1, range2)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{INTEGER}{range1}{start element number}{IN}
C ** \param{INTEGER}{range2}{end element number}{IN}
C ** \paramend 
C ** \blurb{This function sets the range of elements of a structure
C ** content diagram to view in a CONTENT window.}
C */
       INTEGER windid, range1, range2
       external ptk_setcontentviewrange 
& !$PRAGMA C(ptk_setcontentviewrange)

       call ptk_setcontentviewrange(%val(windid), %val(range1), 
& %val(range2))

       RETURN
       END

       SUBROUTINE ptkf_inqcontentviewrange(windid, range1, range2, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{terminal window identifier}{IN}
C ** \param{INTEGER}{range1}{element number}{IN}
C ** \param{INTEGER}{range2}{element number}{IN}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain the viewing range of
C ** a structure content diagram which is posted to a CONTENT window.}
C */
       INTEGER windid, range1, range2, err
       external ptk_inqcontentviewrange
& !$PRAGMA C(ptk_inqcontentviewrange)

       call ptk_inqcontentviewrange(%val(windid), range1, 
& range2, err)

       RETURN
       END

C camera functions 

       SUBROUTINE ptkf_rotatecameraposition(windid, spinangle)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{angle}{rotation angle in degrees}{IN}
C ** \paramend 
C ** \blurb{This function rotates the camera position in a circle centred
C ** at the point of interest and about the axis defined by the function
C ** {\tt ptk\_setpositionaxis}. The amount of rotation is {\tt angle}
C ** degrees and the function is useful for rotating around an object.}
C */
       INTEGER windid
       REAL spinangle
       REAL*8 dpspinangle
       external ptk_rotatecameraposition 
& !$PRAGMA C(ptk_rotatecameraposition)

       dpspinangle = spinangle
       call ptk_rotatecameraposition(%val(windid), %val(dpspinangle))

       RETURN
       END

       SUBROUTINE ptkf_setpositionaxis(windid, axis)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{axis(3)}{axis of rotation}{IN}
C ** \paramend 
C ** \blurb{This function sets the axis of rotation for rotating 
C ** the camera position using the function {\tt ptk\_rotatecameraposition}.}
C */
       INTEGER windid
       REAL axis(3)
       external ptk_setpositionaxis !$PRAGMA C(ptk_setpositionaxis)

       call ptk_setpositionaxis(%val(windid), axis)

       RETURN
       END

       SUBROUTINE ptkf_setptinterestaxis(windid, axis)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{axis(3)}{axis of rotation}{IN}
C ** \paramend 
C ** \blurb{This function sets the axis of rotation for rotating 
C ** the camera point of interest using the function
C ** {\tt ptk\_rotatecameraptinterest}.}
C */
       INTEGER windid
       REAL axis(3)
       external ptk_setptinterestaxis !$PRAGMA C(ptk_setptinterestaxis)

       call ptk_setptinterestaxis(%val(windid), axis)

       RETURN
       END

       SUBROUTINE ptkf_scaleviewwindow(windid, scalefactor)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{scalefactor}{scale factor}{IN}
C ** \paramend 
C ** \blurb{This function scales the view window uniformly
C ** by {\tt scalefactor}. A scalefactor in the range [0, 1] will
C ** scale down the view window and create a zoom-in effect.
C ** A scalefactor greater than 1.0 will give a zoom-out effect.}
C */
       INTEGER windid
       REAL scalefactor
       REAL*8 dpscalefactor
       external ptk_scaleviewwindow !$PRAGMA C(ptk_scaleviewwindow)

       dpscalefactor = scalefactor
       call ptk_scaleviewwindow(%val(windid), %val(dpscalefactor))

       RETURN
       END

       SUBROUTINE ptkf_rotatecameraptinterest(windid, swivelangle)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{angle}{rotation angle in degrees}{IN}
C ** \paramend 
C ** \blurb{This function rotates the camera point of interest in a circle 
C ** centred at the camera position and about the axis defined by the function
C ** {\tt ptk\_setptinterestaxis}. The amount of rotation is {\tt angle}
C ** degrees and the function is useful for panning around a scene.}
C */
       INTEGER windid
       REAL swivelangle
       REAL*8 dpswivelangle
       external ptk_rotatecameraptinterest 
& !$PRAGMA C(ptk_rotatecameraptinterest)

       dpswivelangle = swivelangle
       call ptk_rotatecameraptinterest(%val(windid), 
& %val(dpswivelangle))

       RETURN
       END

       SUBROUTINE ptkf_rotatecameraupvector(windid, twistangle)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{angle}{rotation angle in degrees}{IN}
C ** \paramend 
C ** \blurb{This function rotates the camera up vector 
C ** about the axis joining the camera position to the point of interest by
C ** {\tt angle} degrees.}
C */
       INTEGER windid
       REAL twistangle
       REAL*8 dptwistangle
       external ptk_rotatecameraupvector 
& !$PRAGMA C(ptk_rotatecameraupvector)

       dptwistangle = twistangle
       call ptk_rotatecameraupvector(%val(windid), %val(dptwistangle))

       RETURN
       END

       SUBROUTINE ptkf_rotatepositionxaxis(windid, angle)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{angle}{rotation angle in degrees}{IN}
C ** \paramend 
C ** \blurb{This function rotates the camera position in a circle centred
C ** at the point of interest and about the y axis of a right-handed
C ** coordinate system whose z axis is defined by the camera position
C ** point of interest.}
C */
       INTEGER windid
       REAL angle
       REAL*8 dpangle
       external ptk_rotatepositionxaxis
& !$PRAGMA C(ptk_rotatepositionxaxis)

       dpangle = angle
       call ptk_rotatepositionxaxis(%val(windid), %val(dpangle))

       RETURN
       END

       SUBROUTINE ptkf_rotatepositionyaxis(windid, angle)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{angle}{rotation angle in degrees}{IN}
C ** \paramend 
C ** \blurb{This function rotates the camera position in a circle centred
C ** at the point of interest and about the x axis of a right-handed
C ** coordinate system whose z axis is defined by the camera position
C ** point of interest.}
C */
       INTEGER windid
       REAL angle
       REAL*8 dpangle
       external ptk_rotatepositionyaxis
& !$PRAGMA C(ptk_rotatepositionyaxis)

       dpangle = angle
       call ptk_rotatepositionyaxis(%val(windid), %val(dpangle))

       RETURN
       END

       SUBROUTINE ptkf_rotateptinterestxaxis(windid, angle)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{angle}{rotation angle in degrees}{IN}
C ** \paramend 
C ** \blurb{This function rotates the camera point of interest
C ** in a circle centred
C ** at the camera position and about the y axis of a right-handed
C ** coordinate system whose z axis is defined by the camera position
C ** point of interest.}
C */
       INTEGER windid
       REAL angle
       REAL*8 dpangle
       external ptk_rotateptinterestxaxis
& !$PRAGMA C(ptk_rotateptinterestxaxis)

       dpangle = angle
       call ptk_rotateptinterestxaxis(%val(windid), %val(dpangle))

       RETURN
       END

       SUBROUTINE ptkf_rotateptinterestyaxis(windid, angle)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{angle}{rotation angle in degrees}{IN}
C ** \paramend 
C ** \blurb{This function rotates the camera point of interest
C ** in a circle centred
C ** at the camera position and about the x axis of a right-handed
C ** coordinate system whose z axis is defined by the camera position
C ** point of interest.}
C */
       INTEGER windid
       REAL angle
       REAL*8 dpangle
       external ptk_rotateptinterestyaxis
& !$PRAGMA C(ptk_rotateptinterestyaxis)

       dpangle = angle
       call ptk_rotateptinterestyaxis(%val(windid), %val(dpangle))

       RETURN
       END

       SUBROUTINE ptkf_shiftcamera(windid, shift)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{shift(3)}{shift factor}{IN}
C ** \paramend 
C ** \blurb{This function shifts the camera point of interest
C ** and camera position about the axes of a right-handed
C ** coordinate system whose z axis is defined by the camera position 
C ** and point of interest.}
C */
       INTEGER windid
       REAL shift(3)
       external ptk_shiftcamera !$PRAGMA C(ptk_shiftcamera)

       call ptk_shiftcamera(%val(windid), shift)

       RETURN
       END

       SUBROUTINE ptkf_setcameraposition(windid, position)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{position(3)}{camera position}{IN}
C ** \paramend 
C ** \blurb{This function sets the camera position to {\tt position}
C ** which is given in World Coordinates.}
C */
       INTEGER windid
       REAL position(3)
       external ptk_setcameraposition !$PRAGMA C(ptk_setcameraposition)

       call ptk_setcameraposition(%val(windid), position)

       RETURN
       END

       SUBROUTINE ptkf_setcameraptinterest(windid, ptinterest)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{ptinterest(3)}{point of interest}{IN}
C ** \paramend 
C ** \blurb{This function sets the camera point of interest to
C ** {\tt ptinterest} which is given in World Corrdinates.}
C */
       INTEGER windid
       REAL ptinterest(3)
       external ptk_setcameraptinterest 
& !$PRAGMA C(ptk_setcameraptinterest)

       call ptk_setcameraptinterest(%val(windid), ptinterest)

       RETURN
       END

       SUBROUTINE ptkf_setcameraprojtype(windid, proj)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{INTEGER}{proj}{camera projection type}{IN}
C ** \paramend 
C ** \blurb{This function sets the projection type of the view given by the
C ** camera to PARALLEL or PERSPECTIVE. The default is PARALLEL.}
C */
       INTEGER windid, proj
       external ptk_setcameraprojtype !$PRAGMA C(ptk_setcameraprojtype)

       call ptk_setcameraprojtype(%val(windid), %val(proj))

       RETURN
       END

       SUBROUTINE ptkf_setcamerastate(windid, cameraswitch)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{INTEGER}{cameraswitch}{camera on or off}{IN}
C ** \paramend 
C ** \blurb{This function sets the camera of the window {\tt windid}
C ** to ON or OFF. The default is ON.}
C */
       INTEGER windid
       LOGICAL cameraswitch
       LOGICAL*1 fcameraswitch
       external ptk_setcamerastate !$PRAGMA C(ptk_setcamerastate)

       fcameraswitch = cameraswitch
       call ptk_setcamerastate(%val(windid), %val(fcameraswitch))

       RETURN
       END

       SUBROUTINE ptkf_setcameraworld(windid, num, stids)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{INTEGER}{stids(*)}{structure identifier list}{IN}
C ** \paramend 
C ** \blurb{This function sets the view volume of the camera so 
C ** that it contains the combined bounding box of all the 
C ** structures and structure networks in {\tt stids}.}
C */
       INTEGER windid, num, stids(num)
       external ptkc_setcameraworld !$PRAGMA C(ptkc_setcameraworld)

       call ptkc_setcameraworld(%val(windid), %val(num), stids)

       RETURN
       END

       SUBROUTINE ptkf_setcameralimits(windid, limits, adjust)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{limits(6)}{camera viewing limits in WC}{IN}
C ** \param{LOGICAL}{adjust}{adjust given limits}{IN}
C ** \paramend 
C ** \blurb{This function sets the view volume of the camera
C ** to the specified bounding box given in World Coordinates. If 
C ** {\tt adjust} is set to TRUE then the bounding box will be adjusted 
C ** to be the bounding box of a sphere which encloses the original box.}
C */
       INTEGER windid
       REAL limits(6)
       LOGICAL adjust
       LOGICAL*1 fadjust
       external ptk_setcameralimits !$PRAGMA C(ptk_setcameralimits)

       fadjust = adjust
       call ptk_setcameralimits(%val(windid), limits, %val(fadjust))

       RETURN
       END

       SUBROUTINE ptkf_resetcamera(windid)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \paramend 
C ** \blurb{This function resets the camera variables to their default
C ** values. The camera view volume is left unchanged.}
C */
       INTEGER windid
       external ptk_resetcamera !$PRAGMA C(ptk_resetcamera)

       call ptk_resetcamera(%val(windid))

       RETURN
       END

       SUBROUTINE ptkf_inqcameraposition(windid, position, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{position(3)}{camera position}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain the camera position in
C ** World Coordinates.}
C */
       INTEGER windid
       REAL position(3)
       INTEGER err
       external ptk_inqcameraposition !$PRAGMA C(ptk_inqcameraposition)

       call ptk_inqcameraposition(%val(windid), position, err)

       RETURN
       END

       SUBROUTINE ptkf_inqcameraptinterest(windid, ptinterest, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{ptinterest(3)}{camera point of interest}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain the camera point of interest
C ** in World Coordinates.}
C */
       INTEGER windid
       REAL ptinterest(3)
       INTEGER err
       external ptk_inqcameraptinterest 
& !$PRAGMA C(ptk_inqcameraptinterest)

       call ptk_inqcameraptinterest(%val(windid), ptinterest, err)

       RETURN
       END

       SUBROUTINE ptkf_inqcameraprojtype(windid, projtype, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{INTEGER}{projtype}{camera projection type}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain the camera view projection
C ** type which is either PARALLEL or PERSPECTIVE.}
C */
       INTEGER windid, projtype, err
       external ptk_inqcameraprojtype 
& !$PRAGMA C(ptk_inqcameraprojtype)

       call ptk_inqcameraprojtype(%val(windid), projtype, err)

       RETURN
       END

       SUBROUTINE ptkf_inqcamerastate(windid, switch, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{INTEGER}{cameraswitch}{camera ON/OFF switch}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain the camera state which is
C ** either ON or OFF.}
C */
       INTEGER windid, switch, err
       external ptk_inqcamerastate !$PRAGMA C(ptk_inqcamerastate)

       call ptk_inqcamerastate(%val(windid), switch, err)

       RETURN
       END

       SUBROUTINE ptkf_inqcameralimits(windid, limits, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{limits(6)}{camera world limits}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain the camera view volume.
C ** This defines the volume of a scene that the camera knows about
C ** and is returned in World Coordinates.}
C */
       INTEGER windid
       REAL limits(6)
       INTEGER err
       external ptk_inqcameralimits !$PRAGMA C(ptk_inqcameralimits)

       call ptk_inqcameralimits(%val(windid), limits, err)

       RETURN
       END

       SUBROUTINE ptkf_inqpositionaxis(windid, axis, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{axis(3)}{camera position axis of rotation}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain the axis of rotation
C ** which is used to rotate the camera position in the function
C ** {\tt ptk\_rotatecameraposition}.}
C */
       INTEGER windid
       REAL axis(3)
       INTEGER err
       external ptk_inqpositionaxis !$PRAGMA C(ptk_inqpositionaxis)

       call ptk_inqpositionaxis(%val(windid), axis, err)

       RETURN
       END

       SUBROUTINE ptkf_inqptinterestaxis(windid, axis, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{axis(3)}{camera point of interest axis of rotation}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain the axis of rotation
C ** which is used to rotate the camera point of interest in the function
C ** {\tt ptk\_rotatecameraptinterest}.}
C */
       INTEGER windid
       REAL axis(3)
       INTEGER err
       external ptk_inqptinterestaxis 
& !$PRAGMA C(ptk_inqptinterestaxis)

       call ptk_inqptinterestaxis(%val(windid), axis, err)

       RETURN
       END

	SUBROUTINE ptkf_inqwindowviewrep(windid, 
& vwormt, vwmpmt, vwcplm, xyclpi, bclipi, fclipi, err)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{vwormt(4, 4)}{view orientation matrix}{OUT}
C ** \param{REAL}{vwmpmt(4, 4)}{view mapping matrix}{OUT}
C ** \param{REAL}{vwcplm(6)}{view clipping limits}{OUT}
C ** \param{INTEGER}{xyclpi}{x-y clipping indicator}{OUT}
C ** \param{INTEGER}{bclipi}{back clipping indicator}{OUT}
C ** \param{INTEGER}{fclipi}{front clipping indicator}{OUT}
C ** \param{INTEGER}{err}{error indicator}{OUT}
C ** \paramend
C ** \blurb{This function may be used to obtain the viewing parameters
C ** which are used to set the window view when the camera is switched
C ** OFF.}
C */
     	INTEGER windid      !        window identifier
     	REAL vwormt(4,4)  !        view orientation matrix
     	REAL vwmpmt(4,4)  !        view mapping matrix
     	REAL vwcplm(6)    !        view clipping limits (NPC)
                          !        xmin,xmax,ymin,ymax,zmin,zmax
     	INTEGER xyclpi    !        x-y clipping indicator (PNCLIP,PCLIP)
     	INTEGER bclipi    !        back clipping indicator (PNCLIP,PCLIP)
     	INTEGER fclipi    !        front clipping indicator (PNCLIP,PCLIP)
        INTEGER err
	EXTERNAL ptkc_inqwindowviewrep 
& !$PRAGMA C(ptkc_inqwindowviewrep)

	CALL ptkc_inqwindowviewrep(%val(windid),
& vwormt, vwmpmt, vwcplm, xyclpi, bclipi, fclipi, err)

	RETURN
	END

C viewing functions 

       SUBROUTINE ptkf_setvieworientation3(windid, vrp, vpn, vup, error)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{vrp(3)}{view reference point}{IN}
C ** \param{REAL}{vpn(3)}{view plane normal}{IN}
C ** \param{REAL}{vup(3)}{view up vector}{IN}
C ** \param{INTEGER}{error}{error indicator}{OUT}
C ** \paramend 
C ** \blurb{This function sets the window view orientation values. 
C ** The camera must be switched OFF for these values to be set.}
C */
       INTEGER windid
       REAL vrp(3), vpn(3), vup(3)
       INTEGER error
       external ptk_setvieworientation3 
& !$PRAGMA C(ptk_setvieworientation3)

       call ptk_setvieworientation3(%val(windid), vrp, vpn, vup, error)

       RETURN
       END

       SUBROUTINE ptkf_setviewmapping3(windid, window, viewport, proj, 
& prp, viewplane, backplane, frontplane, error)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{window(4)}{view window}{IN}
C ** \param{REAL}{viewport(6)}{projection viewport}{IN}
C ** \param{INTEGER}{proj}{projection type}{IN}
C ** \param{REAL}{prp(3)}{projection reference point}{IN}
C ** \param{REAL}{viewplane}{view plane distance}{IN}
C ** \param{REAL}{backplane}{back plane distance}{IN}
C ** \param{REAL}{frontplane}{front plane distance}{IN}
C ** \param{INTEGER}{error}{error indicator}{OUT}
C ** \paramend 
C ** \blurb{This function sets the window view mapping values.
C ** The camera must be switched OFF for these values to be set.
C ** The largest square within the window is defined to be the
C ** device coordinates area which the view maps onto.}
C */
       INTEGER windid
       REAL window(4), viewport(6)
       INTEGER proj
       REAL prp(3), viewplane, backplane, frontplane
       INTEGER error
       REAL*8 dpviewplane, dpbackplane, dpfrontplane
       external ptk_setviewmapping3 !$PRAGMA C(ptk_setviewmapping3)

       dpviewplane = viewplane
       dpbackplane = backplane
       dpfrontplane = frontplane
       call ptk_setviewmapping3(%val(windid), window, viewport, 
& %val(proj), prp, %val(dpviewplane), %val(dpbackplane), 
& %val(dpfrontplane), error)

       RETURN
       END

       SUBROUTINE ptkf_setviewclipping3(windid, cliplims, clipxy,
& clipback, clipfront)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{REAL}{cliplims(6)}{view clipping limits}{IN}
C ** \param{INTEGER}{clipxy}{x-y clipping indicator}{IN}
C ** \param{INTEGER}{clipback}{back plane clipping indicator}{IN}
C ** \param{INTEGER}{clipfront}{front plane clipping indicator}{IN}
C ** \paramend 
C ** \blurb{This function sets the window view clipping values. 
C ** The camera must be switched OFF for these values to be set.}
C */
       INTEGER windid
       REAL cliplims(6)
       INTEGER clipxy, clipback, clipfront
       external ptk_setviewclipping3 !$PRAGMA C(ptk_setviewclipping3)

       call ptk_setviewclipping3(%val(windid), cliplims, %val(clipxy),
& %val(clipback), %val(clipfront))

       RETURN
       END

C window type functions 

       SUBROUTINE ptkf_setwindowtype(windid, windtype)
C /*
C ** \parambegin
C ** \param{INTEGER}{windid}{window identifier}{IN}
C ** \param{INTEGER}{windtype}{window type}{IN}
C ** \paramend 
C ** \blurb{This function sets the type of a window to one of
C ** STRUCT, TOPOLOGY, CONTENT and TERMINAL. The default window type is
C ** STRUCT. All items are unposted from the window before the type
C ** is set.}
C */
       INTEGER windid, windtype
       external ptk_setwindowtype !$PRAGMA C(ptk_setwindowtype)

       call ptk_setwindowtype(%val(windid), %val(windtype))

       RETURN
       END


C end of wind.f
